class Solution:
    def isNumber(self, s: str) -> bool:
        s = s.replace('E', 'e')
        idx = -1
        n = len(s)
        for i in range(n):
            if s[i] == 'e':
                if idx != -1: return False
                idx = i
            elif s[i] not in {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '+', '-', '.'}:
                return False
        if idx != -1:
            if idx == n - 1: return False
            s1 = s[:idx]
            s2 = s[idx + 1:]
            if '.' in s2: return False
            if len(s1) == 0 or len(s2) == 0: return False
            return self.isNumber(s1) and self.isNumber(s2)
        d = {'+':0,'-':0}
        for char in s:
            if char in d:
                d[char] += 1
        if sum(d.values()) >= 2: return False
        if s[0] in '+-':
            s = s[1:]
        try:
            float(s)
        except Exception as e:
            return False
        return True


if __name__ == '__main__':
    s = Solution()
    r = s.isNumber("-.7e+-0435")
    print(r)